<%--
  Created by IntelliJ IDEA.
  User: 润
  Date: 2021/7/24
  Time: 19:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>login</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        html {
            height: 100%;
            width: 100%;
            overflow: hidden;
            margin: 0;
            padding: 0;
            background: url(./img/Desert.jpg) no-repeat 0px 0px;
            background-repeat: no-repeat;
            background-size: 100% 100%;
            -moz-background-size: 100% 100%;
        }

        body {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100%;
        }

        #loginDiv {
            width: 37%;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 300px;
            background-color: rgba(75, 81, 95, 0.3);
            box-shadow: 7px 7px 17px rgba(52, 56, 66, 0.5);
            border-radius: 5px;
        }

        #name_trip {
            margin-left: 50px;
            color: red;
        }

        p {
            margin-top: 30px;
            margin-left: 20px;
            color: azure;
        }

        input {
            margin-left: 15px;
            border-radius: 5px;
            border-style: hidden;
            height: 30px;
            width: 140px;
            background-color: rgba(216, 191, 216, 0.5);
            outline: none;
            color: #f0edf3;
            padding-left: 10px;
        }

        .button {
            border-color: cornsilk;
            background-color: rgba(100, 149, 237, .7);
            color: aliceblue;
            border-style: hidden;
            border-radius: 5px;
            width: 100px;
            height: 31px;
            font-size: 16px;
        }
    </style>
    <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
        <script type="text/javascript">
            $(function () {
                $("#submit").click(function () {
                    var username=document.getElementById("userId").value;
                    var password=document.getElementById("passwordId").value;
                    var action =document.getElementById("hidden").value;
                    var para= {

                        action:'queryAll',

                       username:username,

                        password:password
                    };
                    $.ajax({
                        type:"POST",
                        url:"http://localhost:8080/Anyview//StudentServlet?action=login",
                        data:{"username":username,"password":password},
                        success:function (data) {
                            if(data.result1){
                                alert("登录成功！");
                                window.location.href="http://localhost:8080/Anyview//StudentServlet?"+$.param(para);
                            }
                            if(data.result2){
                                alert("学号或者密码错误！");
                                $("#userId").val("");
                                $("#passwordId").val("");
                            }
                        },
                        dataType:"json"
                    })

                })
            })
    </script>
</head>
<body>
 <div id="loginDiv">
    <form  id="form">
        <h1 style="text-align: center;color: aliceblue;">登陆</h1>
        <p>用户名:<input id="userId" type="text" name="username"><label id="name_trip"></label></p>

        <p>密码:  <input id="passwordId" type="password" name="password"><label id="password_trip"></label></p>
        <div style="text-align: center;margin-top: 30px;">
            <button  type="button" id="submit" >登录</button><br>
            <input type="hidden" id="hidden" name="action" value="login">
        </div>
        <div>
            <a href="managerLogin.jsp">我是管理员</a>
        </div>

    </form>
</div>
</body>
</html>

